<?php

declare(strict_types=1);

namespace app\model\system;

use owns\interface\OwnsModelInteface;

class ResourceModel extends OwnsModelInteface
{
    protected $name = 'system_resource';

    protected $updateTime = false;

    /**
     * 查询条件
     * @param object $query
     * @param array $param
     */
    public function scopeCustom(object $query, array $param)
    {
        if ($name = $param['name'] ?? '') {
            $query->whereLike('name', '%' . $name . '%');
        }
        if ($group = $param['group'] ?? '') {
            $query->where('group', $group);
        }
        if ($type = $param['type'] ?? '') {
            $query->where('type', $type);
        }
    }

    /**
     * 类型
     */
    public static function typeList()
    {
        return [
            'image' => '图片',
            'video' => '视频',
            'audio' => '音频',
            'other' => '其他文件'
        ];
    }
}
